 <meta charset="utf-8">
 <div class="card" id="biz_deviceSolutionConfig_conatainer" style="padding-bottom: 0px;">
 
   
 <div class="card">
 	<div class="card-body">
 	<div class="row">
 	
 	  <div class="col-md-2">
             <div class="table-responsive">
               <table class="table mb-0">
                   <thead>
                       <tr>
                           <th><div class="alert alert-danger mb-0" role="alert">当前设备：<strong>【{{device.name}}】</strong>
                          	 	 </div>
                           </th>
                       </tr>
                   </thead>
                   <tbody>
                       <tr v-for="(solution,index) in solutionListConfiged">
                           <td><button class="btn btn-outline btn-primary btn-block" 
                           v-on:click="loadAlgorithmsSolutionbinded(solution)">{{solution.name}}
                          <!--  <i class="far fa-trash-alt"></i> -->
                           </button></td>
                       </tr>
                   </tbody>
               </table>
               <a href="javascript:void(0);" v-on:click="bingSolution" class="btn btn-danger btn-block ">
               	<i class="mdi mdi-plus mr-1"></i>添加新解决方案
               </a>   
             </div>
 	  </div>
 	  
 	  <div class="col-md-2">
  			<div class="card h-100">
                                    <div class="card-body email-leftbar">
                                        <a href="javascript:void(0);" class="btn btn-danger btn-block btn-rounded waves-effect waves-light">
                                        <i class="mdi  mr-1"></i> {{nowSolution.name}}</a>

                                        <div class="mail-list mt-4">
                                            <a href="javascript:void(0);" v-bind:class="{active:item.id==nowAlgorithm.id }"
                                            		   v-for="(item,index) in algorithmListSolutionbinded "
                                            		   v-on:click="loadAlgorithmConfig(item)">
                                            	<i class="mdi mdi-inbox mr-2"></i> {{item.name}}
                                            </a>
                                          
                                        </div>
                                    </div>
                                </div>
                                        
                           
                                        
                                        
 	  </div>
 	  
 	  
 	      <div class="col-md-8">
 	  
 	  			<iframe 
		 	  			id="algorithmConFigIframe" 
		 	  			ref="algorithmConFigIframe" 
		 	  			src="" 
		 	  			width="100%" 
		 	  			height="100%" 
		 	  			style="border: 0px;
		 	  			min-height: 600px;"></iframe>
		                                        
 	  </div>
 	  
 	  
 	
 	</div>
 	</div>
 	</div>
 	
 </div>
<script>
var anewaz=new Vue({  
	  el: '#biz_deviceSolutionConfig_conatainer', 
	  data:{
		  deviceId: null,
		  nowSolution:{},
		  solutionListConfiged:[],
		  algorithmListSolutionbinded:[],
		  nowAlgorithm:{},
		  device:{},
	      bus:new Vue()
	  },
	  mounted:function(){
		 var _this=this;
		 var deviceId=store.get("_vv_deviceId");
		 _this.deviceId=deviceId;
		 _this.loadDevice();
		 _this.loadSolutionsDeviceConfiged();
	  },

    methods: {
    	loadDevice: function(){
   		 var _this=this;
   		 var url="/manger/device/loadDevice";
       	 var param=zfesLayerEditDg.getLayerParam();
   		 zfesAjax.ajaxTodo(url,{id:_this.deviceId}, function(data){
       		 _this.device=data.data.device;
       	 })
		},
		loadSolutionsDeviceConfiged: function(){
	  		 var　_this=this;
	  		 var url="/manager/solutionDevice/loadSolutionsDeviceConfiged";
			    zfesAjax.ajaxTodo(url, {deviceId:_this.deviceId}, function(data) {
					_this.solutionListConfiged=data.data.solutionListConfiged;
					if(_this.solutionListConfiged&&_this.solutionListConfiged.length>0){
						_this.nowSolution=_this.solutionListConfiged[0];
						_this.loadAlgorithmsSolutionbinded(_this.nowSolution);
					}
					
				});
	 	 },
	 	bingSolution: function(){
	 		var _this=this;
  			var url="/view/device/config/device.solution.select.html";
  			zfesLayerEditDg.open(url,{deviceId:_this.deviceId},"编辑",460,function(){_this.loadSolutionsDeviceConfiged();}); 
	 	 },
	 	 
	 	loadAlgorithmsSolutionbinded: function(solution){
	 		 var　_this=this;
	 		_this.nowSolution=solution;
	 		var url="/manager/solution/algorithm/loadAlgorithmsSolutionBinded";
	 		zfesAjax.ajaxTodo(url, {solutionId: solution.id}, function(data) {
				_this.algorithmListSolutionbinded=data.data.algorithmList;
				
				if(_this.algorithmListSolutionbinded&&_this.algorithmListSolutionbinded.length>0){
					_this.nowAlgorithm=_this.algorithmListSolutionbinded[0];
					_this.loadAlgorithmConfig(_this.nowAlgorithm);
				}
				
			});
	 	},
	 	loadAlgorithmConfig: function(algorithm){
	 		 var　_this=this;
		 	 _this.nowAlgorithm=algorithm;
		 	 
		 	store.set('ifream_param_', {algorithmId: _this.nowAlgorithm.id,deviceId: _this.deviceId,solutionId: _this.nowSolution.id});
     		document.getElementById('algorithmConFigIframe').src="/view/device/config/tree.html";
     		
	 	},
     	editConfigItemValue: function(configItemValueId){
     		 var　_this=this;
      		var param={itemId:configItemValueId,algorithmId:_this.nowAlgorithm.id,deviceId:_this.deviceId,solutionId:_this.nowSolution.id};
      		console.log("--editConfigItemValue--",param);
      		 var url="/view/device/config/device.solution.config.value.edit.html";
     		 zfesLayerEditDg.open(url,param,"编辑",460,function(){
     			 
     			store.set('ifream_param_', {algorithmId:_this.nowAlgorithm.id,deviceId:_this.deviceId,solutionId:_this.nowSolution.id});
         		document.getElementById('algorithmConFigIframe').src="/view/device/config/tree.html";
         		
     		 });
     	},
  	 
	  
  	save: function(){
 		 var　_this=this;
 		 console.log(_this.itemValueList);
 		 $.ajax({
             type: "POST",
             url: "/manger/aIConfigItemValue/saveItemValues?cateId="+_this.nowcate.id+"&deviceId="+_this.device.id+"",
             contentType: "application/json;charset=utf-8",
             data:JSON.stringify(_this.itemValueList),
             dataType: "json",
             success:function (message) {
                if(message.statusCode==200){
                	alertSwal.successText(message.message);
                }else{
                	alertSwal.warningText(message.message);
                }
             },
             error:function (message) {
            	 alertSwal.warningText(message);
             }
         });
 		 
 	  },
 	
	  
   	
   }

});

function showDetail(row){
	anewaz.showDetail(row);
}
</script>


